<?php
class Somi_Plugin_ModuleSetup extends Zend_Controller_Plugin_Abstract
{
	public function routeShutdown(Zend_Controller_Request_Abstract $request)
	{
		$module=$request->getModuleName();
		$file='ModuleInit.php';
		
		if('default'==$module)
		{
			$path=APPLICATION_PATH.'/default/';
			$class='ModuleInit';
		}else{
			$path=APPLICATION_PATH.'/'.$module.'/';
			$class=ucfirst($module).'_ModuleInit';
		}
		
		if(Zend_Loader::isReadable($path . $file)){
			Zend_Loader::loadFile($file,$path);
			$plugin=new $class();
			$plugin->setRequest($request);
			$plugin->setResponse($this->getResponse());
			
			Zend_Controller_Front::getInstance()->registerPlugin($plugin);
		}
		
	}
}

?>